Unit BDijitFormWidgetUnit;

{$mode objfpc}{$H+}

Interface

Uses
  Classes, SysUtils, BDijitWidgetUnit;

//TODO: add templated mixin

Type

{ BDijitFormWidgetClass }

  //** Represents a single HTML element. All these widgets should have these
  //** attributes just like native HTML input elements. You can set them during
  //** widget construction or afterwards, via dijit._Widget.attr. They also
  //** share some common methods.

 BDijitFormWidgetClass = Class(BDijitWidgetClass)
  Private
    bAlt: String;
    bDisabled: Boolean;
    bHTMLType: String;
    bIntermediateChanges: Boolean;
    bName: String;
    bScrollOnFocus: Boolean;
    bTabIndex: Integer;
    bValue: String;
    Procedure SetAlt(aValue: String);
    Procedure SetDisabled(aValue: Boolean);
    Procedure SetHTMLType(aValue: String);
    Procedure SetIntermediateChanges(aValue: Boolean);
    Procedure SetName(aValue: String);
    Procedure SetScrollOnFocus(aValue: Boolean);
    Procedure SetTabIndex(aValue: Integer);
    Procedure SetValue(aValue: String);
  Public
    //** Corresponds to the native HTML <input> element's attribute.
    Property Alt: String Read bAlt Write SetAlt;
    //** Should this widget respond to user input? In markup, this is specified
    //** as "disabled='disabled'", or just "disabled".
    Property Disabled: Boolean Read bDisabled Write SetDisabled;
    //** Fires onChange for each value change or only on demand
    Property IntermediateChanges: Boolean Read bIntermediateChanges
      Write SetIntermediateChanges;
    //** Name used when submitting form; same as "name" attribute or plain
    //** HTML elements
    Property Name: String Read bName Write SetName;
    //** On focus, should this widget scroll into view?
    Property ScrollOnFocus: Boolean Read bScrollOnFocus Write SetScrollOnFocus;
    //** Order fields are traversed when user hits the tab key
    Property TabIndex: Integer Read bTabIndex Write SetTabIndex;
    //** Corresponds to the native HTML <input> element's attribute.
    Property HTMLType: String Read bHTMLType Write SetHTMLType;
    //** Corresponds to the native HTML <input> element's attribute.
    Property Value: String Read bValue Write SetValue;

    //** Put focus on this widget
    Procedure Focus;
End;

Implementation

{ BDijitFormWidgetClass }

Procedure BDijitFormWidgetClass.SetAlt(aValue: String);
Begin
  bAlt := aValue;
  SetConfig('alt', aValue);
End;

Procedure BDijitFormWidgetClass.SetDisabled(aValue: Boolean);
Begin
  bDisabled := aValue;
  SetConfig('disabled', aValue);
End;

Procedure BDijitFormWidgetClass.SetHTMLType(aValue: String);
Begin
  bHTMLType := aValue;
  SetConfig('type', aValue);
End;

Procedure BDijitFormWidgetClass.SetIntermediateChanges(aValue: Boolean);
Begin
  bIntermediateChanges:=aValue;
  SetConfig('intermediateChanges', aValue);
End;

Procedure BDijitFormWidgetClass.SetName(aValue: String);
Begin
  bName := aValue;
  SetConfig('name', aValue);
End;

Procedure BDijitFormWidgetClass.SetScrollOnFocus(aValue: Boolean);
Begin
  bScrollOnFocus := aValue;
  SetConfig('scrollOnFocus', aValue);
End;

Procedure BDijitFormWidgetClass.SetTabIndex(aValue: Integer);
Begin
  bTabIndex := aValue;
  SetConfig('tabIndex', aValue);
End;

Procedure BDijitFormWidgetClass.SetValue(aValue: String);
Begin
  bValue := aValue;
  SetConfig('value', aValue);
End;

Procedure BDijitFormWidgetClass.Focus;
Begin
  AddAjax('focus();');
End;

End.

